//
//  UIImageVIew+Ext.swift
//  微博
//
//  Created by xm on 2018/3/27.
//  Copyright © 2018年 xm. All rights reserved.
//

import Foundation
import SDWebImage

extension UIImageView{
    
    func sd_setImage(urlString: String?,placeholderImage: UIImage?,isAvatar: Bool=false){
        
        guard let urlString = urlString,
            let url = URL(string: urlString) else {
             image=placeholderImage//使用默认图片
                
             return
        }
        
        sd_setImage(with: url, placeholderImage: placeholderImage,
                    options: [], progress: nil) { [weak self] (image, _, _, _) in
                        //是头像，使用圆形
                        if isAvatar {
                            self?.image=image?.avatarImage(size: self?.bounds.size)
                        }
        }
        
        
    }
    
}
